#include "qstringhandle.h"
#include <QDebug>
QStringHandle::QStringHandle()
{

}

QStringList strutils::explode(const QString &sSeparator, const QString &sString)
{
//    qDebug()<<"分割符:"<<sSeparator <<" Src:"<<sString;
    QStringList qList;
    if (sString.length() > 0)
    {
        qList = sString.split(sSeparator);
        if ((sString.size() - sString.lastIndexOf(sSeparator)) == sSeparator.size())
        {
            qList.removeAt(qList.size()-1);
        }
    }

    return qList;
}

QString strutils::variantToQString(const QVariant data)
{
    QString str;
    switch (data.type())
    {
    case QMetaType::Int:
        str = QString::number(data.toInt());
        break;
    case QMetaType::UInt:
        str = QString::number(data.toUInt());
        break;
    case QMetaType::LongLong:
        str = QString::number(data.toLongLong());
        break;
    case QMetaType::Double:
        str = QString::number(data.toDouble());
        break;
    case QMetaType::QString:
        str = data.toString();
        break;
    case QMetaType::QChar:
        str = QString(data.toChar());
        break;
//    case VT_BSTR:
//        str = QString((QChar*)data->bstrVal, wcslen(data->bstrVal));
//    break;
//    case VT_DATE:
//        str = QString::fromUtf16((ushort*)LPCTSTR(COleDateTime(data->date).Format(L"%Y%m%d")));
//        break;
    default:
        qDebug()<<"Error: variantToQString undefine transfer:"<<data.type();
    }
    return str;
}
